package com.liuwa.openapi.controller;

import com.liuwa.openapi.common.BaseController;
import com.liuwa.common.core.domain.Result;
import com.liuwa.common.utils.bean.BeanUtils;
import com.liuwa.knowledge.domain.Module;
import com.liuwa.knowledge.query.ModuleQuery;
import com.liuwa.knowledge.service.ModuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 模块Controller
 * 
 * @author liuwa
 * @date 2025-04-03 08:31:16
 */
@RestController
@Api(value = "模块")
@RequestMapping("/openapi/modules")
public class OpenapiModuleController extends BaseController{

    @Autowired
    private ModuleService moduleService;

    /**
     * 查询模块列表
     */
    @ApiOperation("查询模块列表")
    @GetMapping
    public Result.ItemsVo list(ModuleQuery query)
    {
        Module condition = new Module();
        BeanUtils.copyBeanNotNull2Bean(query, condition);
        List<Module> list = moduleService.findList(condition);
        return Result.items(list);
    }



    /**
     * 获取模块详细信息
     */
    @ApiOperation("获取模块详细信息")
    @GetMapping(value = "/{id}")
    public Module get(@PathVariable("id") Integer id)
    {
        return moduleService.get(id);
    }


}
